<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>SQL发布管理</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub">SQL发布管理</span>
    </div>

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;">
                        <table style="width:100%;">
                            <tbody>
                                <tr>
                                    <td height="27px" style="width:75%;">

                                        <span>当前用户名：<!--{$currentUser}--></span>
                                        <span>发布人：<input type="text" style="width:150px;" id="creator" name="creator" value=""></span>
                                        <span> 操作表名称： <input type="text" style="width:150px;" id="tableName" name="tableName" value=""></span>
                                        <span>
                                            项目：
                                             <select id="projectID" name="projectID" style="width:150px;">
                                                 <option value="">请选择</option>
                                                 <!--{foreach from=$projectList item=project}-->
                                                 <option value="<!--{$project.projectID}-->" ><!--{$project.projectName}--></option>
                                                 <!--{/foreach}-->
                                             </select>
                                        </span>
                                        <span><input type="button" value="查询" id="searchBtn" class="btn" onclick="sqlProject.search();" /></span>
                                        <span><input type="button" value="重置" id="clearBtn" class="btn" onclick="sqlProject.clearUp();" /></span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>


</div>

<script type="text/javascript">

    //接收当前登录人
    var currentUser = '<!--{$currentUser}-->';

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/project/projectSql.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 100, align: "center"},
            {display: "发布人", width : 150,align:"left"},
            {display: "发布序号", name : "seqno", width : 100, sortable : true,align:"left"},
            {display: "发布时间", width : 150,align:"center"},
            {display: "所属项目", width : 150},
            {display: "备注", width : 470,align:"left"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "sqlProject.add"}
        ],
        sortname: "seqno",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        nowrap : false,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var sqlProject = {

        delArr: new Array(),

        seqno:'',

        //搜索
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加
        add: function() {
            E.open("/quanliadmin/app/project/projectSql.pscript?operFlg=3", "", {height: 600,width: 980, top: 50, left: 150});
        },

        //详情
        detail:function(seqno){
            E.open("/quanliadmin/app/project/projectSql.pscript?operFlg=4&seqno=" + seqno, "", {height: 600,width: 980, top: 50, left: 150});
        },

        //查看SQL
        look:function(seqno){
            E.open("/quanliadmin/app/project/projectSql.pscript?operFlg=5&seqno=" + seqno, "", {height: 600,width: 980, top: 50, left: 150});
        },

        //回调函数
        callback: function( obj ) {

            if( obj.code == 200 ){
                E.alert( obj.message , 2 , 'sqlProject.load');
            }else{
                E.alert(obj.message);
            }

        },

        load: function() {
            $("#flex").flexReload();
        },

        //重置
        clearUp:function(){
            $("#projectID").val('');
            $("#creator").val('');
            $("#tableName").val('');
        }

    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/project/projectSql.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

</script>

</body>

</html>
